<template>
  <div class="w750 white-bg">
    <!-- {{integralName}}规则 -->
    <div class="integral-rule">
      <div class="item">
        <p class="rule-tit">如何获得{{integralName}}</p>
        <p class="rule-txt">1. 绑定手机送{{integralName}}</p>
        <p class="rule-txt">2. 关注微信公众号（敬请期待）</p>
        <p class="rule-txt">3. 签到送{{integralName}}（敬请期待）</p>
        <p class="rule-txt">4. 所有/部分商品消费N元送N{{integralName}}</p>
      </div>
      <div class="item">
        <p class="rule-tit">获得的{{integralName}}如何花</p>
        <p class="rule-txt">1. 购物抵现，一元抵扣{{integralRule.deducteIntegral == 0 || integralRule.deducteIntegral == null  ? ' N ' : ' ' + integralRule.deducteIntegral}} {{integralName}}，最高 {{integralRule.deductionRate == 0  || integralRule.deducteIntegral == null ? ' N ' : integralRule.deductionRate}} %上限</p>
      </div>

      <div class="item" style="border:none;">
        <p class="rule-tit">{{integralName}}有效期</p>
        <p class="rule-txt">1. {{integralName}}状态：</p>
        <p class="rule-txt" style="text-indent: 2em;">收入，支出，冻结三个状态</p>
        <p class="rule-txt" style="text-indent: 2em;">收入：是指通过所有渠道获得的{{integralName}}</p>
        <p class="rule-txt" style="text-indent: 2em;">支出：是指消耗的{{integralName}}</p>
        <p class="rule-txt" style="text-indent: 2em;">冻结：是指处于保护期内的{{integralName}}，当订单整单退款时，保护期内的{{integralName}}将被回收（购买金额X元和满减送活动赠送的{{integralName}}有{{integralRule.protectionDate == 0 ? ' N ' : integralRule.protectionDate}}天保护期）</p>
        <p class="rule-txt">2. {{integralName}}有效期：{{integralRule.expirationType == 0 ? `当前获得${integralName}永久有效` : `每笔${integralName}固定有效期${integralRule.protectionDate == 0 ? ' N ' : integralRule.protectionDate}天`}}</p>
        <p class="rule-txt">3. 优先使用即将过期的{{integralName}}</p>
        <p class="rule-txt">4. {{integralName}}扣减规则：通过下单的{{integralName}}，在订单退回时，会相应扣减{{integralName}}</p>
        <p class="rule-txt">5. {{integralName}}退回规则：下单是使用{{integralName}}抵现金，整笔订单退款时，则会退回所有未失效的{{integralName}}</p>
      </div>

    </div>
    <!-- /{{integralName}}规则 -->
  </div>
</template>

<script>
import { getRule } from "api/pointsApi";
import { mapState } from "vuex";
export default {
  data() {
    return {
      integralRule: {
        deducteIntegral: 0,  //XX{{integralName}}抵扣一元
        deductionOpen:false,  //是否开启{{integralName}}抵扣
        deductionRate: 0,  //每个订单最高抵扣比例
        exclusiveCoupon: false, //是否可以和优惠卷共同使用
        expirationDate: 0, // 有效期（以天算
        expirationType: 0, //有效期类型, 0: 永久有效, 10: 每笔{{integralName}}固定有效期
        integralLimit: 0, // 用户每天获得的{{integralName}}上限
        phoneIntegral: 0, //绑定手机号获得{{integralName}}
        protectionDate: 0,  //{{integralName}}获得保护期(以天算)
      }
    };
  },
  mounted() {
    this.loadRule()
  },
  computed: {
		...mapState(["integralName"]),
	},
  methods: {
    async loadRule() {
      try {
        let res = await getRule()

        if (res.status != 1) {
          this.$toast(res.msg)
          return
        }
        // res.result.deducteIntegral = 2
        this.integralRule = {...this.integralRule,...res.result} 

      } catch (error) {
      }

    }
  },
  beforeRouteEnter (to, from, next) {
		next(vm => {
			vm.$nextTick(()=> {
				to.meta.titleName = vm.$store.state.integralName + '规则'
				to.meta.title =  vm.$store.state.integralName + '规则'
				document.title = vm.$store.state.integralName + '规则'	
			})
		})
	},
  components: {}
};
</script>

<style src="../../assets/css/pre-deposit.css" scoped></style>